import { createRouter, createWebHistory } from 'vue-router'

import IndexView from '@/views/index/index.vue'
import LayoutView from '@/views/layout/index.vue'
import LoginView from '@/views/login/index.vue'
import TemperatureView from '@/views/history/temperature.vue'
import HumidityView from '@/views/history/humidity.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/', 
      name: '', 
      component: LayoutView,
      redirect: '/index', //重定向
      children: [
        { path: 'index', name: 'index', component: IndexView},
        { path: 'temperature', name: 'temperature', component: TemperatureView},
        { path: 'humidity', name: 'humidity', component: HumidityView}
      ]
    },
    { path: '/login', name: 'login', component: LoginView}
  ]
})

export default router
